package editeurGraphiti.features;

import modeleProcessus.Acteur;

import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.IResizeShapeFeature;
import org.eclipse.graphiti.features.context.IResizeShapeContext;
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature;
import org.eclipse.graphiti.mm.pictograms.Shape;

public class ResizeActeurFeature extends DefaultResizeShapeFeature {

	public ResizeActeurFeature(IFeatureProvider fp) {
		super(fp);
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean canResizeShape(IResizeShapeContext context) {
		boolean canResize = super.canResizeShape(context);

		// perform further check only if move allowed by default feature
		if (canResize) {
			// don't allow resize if the class name has the length of 1
			Shape shape = context.getShape();
			Object bo = getBusinessObjectForPictogramElement(shape);
			if (bo instanceof Acteur) {
				Acteur acteur = (Acteur) bo;
				if (acteur.getNomElement() != null
						&& acteur.getNomElement().length() == 1) {
					canResize = false;
				}
			}
		}
		return canResize;
	}

	@Override
	public void resizeShape(IResizeShapeContext context) {
		super.resizeShape(context);
		Shape shape = context.getShape();
	}
}
